home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / libc / Net_AddrToString.c < prev    next >
C/C++ Source or Header  |  1990-09-11  |  2KB  |  77 lines

  1. /* 
  2.  * Net_AddrToString.c --
  3.  *
  4.  *    Converts a Net_Address into a printable string.
  5.  *
  6.  * Copyright 1990 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  */
  15.  
  16. #ifndef lint
  17. static char rcsid[] = "$Header: /sprite/src/lib/net/RCS/Net_AddrToString.c,v 1.2 90/09/11 14:43:47 kupfer Exp $ SPRITE (Berkeley)";
  18. #endif /* not lint */
  19.  
  20. #include <sprite.h>
  21. #include <stdio.h>
  22. #include <net.h>
  23.  
  24. /*
  25.  *----------------------------------------------------------------------
  26.  *
  27.  * Net_AddrToString --
  28.  *
  29.  *    Converts a Net_Address into a printable string.
  30.  *
  31.  * Results:
  32.  *    Pointer to the string.
  33.  *
  34.  * Side effects:
  35.  *    None.
  36.  *
  37.  *----------------------------------------------------------------------
  38.  */
  39.  
  40. char    *
  41. Net_AddrToString(netAddressPtr, protocol, netType, buffer)
  42.     Net_Address        *netAddressPtr;    /* Network address. */
  43.     int            protocol;    /* Network protocol (eg raw, inet). */
  44.     Net_NetworkType    netType;    /* Type of network (eg ether). */
  45.     char        *buffer;    /* The string buffer. */
  46. {
  47.     *buffer = '\0';
  48.     switch(protocol) {
  49.     case NET_PROTO_RAW: {
  50.         switch(netType) {
  51.         case NET_NETWORK_ETHER:
  52.             return Net_EtherAddrToString(&netAddressPtr->ether, buffer);
  53.             break;
  54.         case NET_NETWORK_ULTRA: {
  55.             int        group;
  56.             int        unit;
  57.             Net_UltraAddressGet(&netAddressPtr->ultra, &group, &unit);
  58.             sprintf(buffer, "%d/%d", group, unit);
  59.             break;
  60.         }
  61.         default:
  62.             return buffer;
  63.         }
  64.         break;
  65.     }
  66.     case NET_PROTO_INET: {
  67.         return Net_InetAddrToString(netAddressPtr->inet, buffer);
  68.         break;
  69.     }
  70.     default:
  71.         return buffer;
  72.         break;
  73.     }
  74.     return buffer;
  75. }
  76.  
  77.